package cn.cxq.learning.string_matching;

import org.junit.jupiter.api.Test;

public class Client {

    @Test
    public void testViolentMatch() {
        String matchingStr = "bc abcaabca abcacacbcab abcacacbcaa bacabbc";
        String matchedStr = "cacbcaa";
        ViolentMatch violentMatch = new ViolentMatch(matchingStr, matchedStr);
        violentMatch.search(); //28
    }

    @Test
    public void testKMPAlgorithmMatch() {
        String matchingStr = "bc abcaabca abcacacbcab abcacacbcaa bacabbc";
        String matchedStr = "cacbcaa";
        KMPAlgorithmMatch kmpAlgorithmMatch = new KMPAlgorithmMatch(matchingStr, matchedStr);

        System.out.println("部分匹配值表：");
        kmpAlgorithmMatch.showNext();

        kmpAlgorithmMatch.search(); //28
    }
}
